package com.shxzz.easy12306.services.order.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shxzz.easy12306.services.order.dao.entity.OrderItemDO;
import com.shxzz.easy12306.services.order.dao.mapper.OrderItemMapper;
import com.shxzz.easy12306.services.order.dto.req.TicketOrderItemQueryReqDTO;
import com.shxzz.easy12306.framework.starter.common.dto.order.TicketOrderPassengerDetailRespDTO;
import com.shxzz.easy12306.services.order.service.OrderItemService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 订单项服务层接口实现
 */
@RequiredArgsConstructor
@Service
public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OrderItemDO> implements OrderItemService {

    @Override
    public List<TicketOrderPassengerDetailRespDTO> queryTicketItemOrderById(TicketOrderItemQueryReqDTO requestParam) {
        LambdaQueryWrapper<OrderItemDO> queryWrapper = Wrappers.lambdaQuery(OrderItemDO.class)
                .eq(OrderItemDO::getOrderSn, requestParam.getOrderSn())
                .in(OrderItemDO::getId, requestParam.getOrderItemRecordIds());
        List<OrderItemDO> orderItemDOS = baseMapper.selectList(queryWrapper);
        return BeanUtil.copyToList(orderItemDOS, TicketOrderPassengerDetailRespDTO.class);
    }
}




